<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组合式API</title>
  </head>
  <body>
    <div id="app">
      {{ count }} - {{ doubleCount }}
      <button @click="add">1</button>
      <button @click="count += 10">10</button>
    </div>
  </body>
  <script src="../lib/vue.global.js"></script>
  <script>
    const { ref } = Vue;
    Vue.createApp({
      setup() {
        const count = ref(100);
        console.log(count.value);
        const add = () => {
          count.value = count.value + 1;
        };
        return {
          count,
          add,
        };
      },
      computed: {
        doubleCount() {
          return this.count + 2;
        },
      },
    }).mount("#app");
  </script>
</html>
